package cn.edu.scau.dormitory_management_system.controller;

import cn.edu.scau.dormitory_management_system.constant.Consts;
import cn.edu.scau.dormitory_management_system.entity.DepartmentEntity;
import cn.edu.scau.dormitory_management_system.entity.UserEntity;
import cn.edu.scau.dormitory_management_system.module.examine.entity.VO.CheckinApplicationVO;
import cn.edu.scau.dormitory_management_system.service.DepartmentService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ：Vizzk
 * @description：TODO
 * @date ：2021/8/18 14:16
 */
@RestController
@RequestMapping("/admin/dept")
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;

    @GetMapping("/listAllDepts")
    public Object listAllDepts(@RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "20") Integer pageSize){
        IPage<DepartmentEntity> page = departmentService.listAllDepts(pageNum, pageSize);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put(Consts.CODE, 200);
            jsonObject.put(Consts.MSG, "查询成功");
            jsonObject.put("page",page);
        } catch (Exception e){
            jsonObject.put(Consts.CODE, 0);
            jsonObject.put(Consts.MSG, "查询失败");
        }
        return jsonObject;
    }
}
